<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        function fn(n){
            var arr=new Array(n);
            var average=0;
            var newarr=[];
            // 初始化数组
            for(var i=0;i<arr.length;i++)
            {
                arr[i]=(i+1)*2;
            }
            console.log(arr)
            var j=0;var times=0;
        for(i=0;i<arr.length/5;i++)//新数组下标i
        {
            // for(;;++j)
            // {
            //     average+=arr[j]; 
            //     times++;
            //     if ((times)===5)
            //     { 
            //         average/=5;
            //         newarr[i]=average;
            //         times=0;average=0;j++;
            //         break;
            //     }
            // }    
            while(1)
            {
                average+=arr[j]; 
                times++;
                j++;
                if ((times)===5)
                { 
                    average/=5;
                    newarr[i]=average;
                    times=0;average=0;
                    break;
                }
            }   
        }
            console.log(newarr);
        }
        fn(30);
    </script>
</body>
</html>